<style>
.item-btn{text-align:center;padding-bottom:15px;}
.item-sbtn{padding:15px 35px 30px 35px;}
.item-sbtn .layui-btn{float: right;}
.layui-append .layui-form-label{width:100px;padding-left:0;}
.append_label{cursor:pointer;}
.layui-append .layui-form-item{	margin-top: 5px;}
.append_not .append_label{color:#999}
.append_not .layui-input-block{display:none;}
</style>
<form class="layui-form layui-font14 layui-append" name="append" action>
<script type="text/javascript">
var maxnum=5,stop=1000,Rsdata;
$.getScript("/static/thinkct/js/plupload.js", function() {
//创建实例的构造方法
uploader = new plupload.Uploader({
				//上传插件初始化选用那种方式的优先级顺序
                runtimes: 'html5,flash,silverlight,html4', 
                // 上传按钮
				browse_button: 'browse', 
                //上传地址
				url: "/upload/", 
			    resize: {width: 900},  
				max_retries: 1,
				//flash文件地址
                flash_swf_url: '/static/thinkct/js/Moxie.swf', 
                //silverlight文件地址
				silverlight_xap_url: '/static/thinkct/js/Moxie.xap', 
                filters: {
					//不允许队列中存在重复文件
					prevent_duplicates : true, 
                    //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
					max_file_size:'5mb', 
                    //允许文件上传类型
					mime_types: [
                        {title: "选择文件", extensions:'jpg,png,gif,txt,pdf,doc,docx,xls,xlsx,zip,rar'}
                    ]
                },
				//true:ctrl多文件上传, false 单文件上传
                multi_selection: true 
	});
	//初始化
	uploader.init(); 
	//绑定文件添加进队列事件	

	uploader.bind('FilesAdded',function(uploader,files){
	var newnum=maxnum-parseInt($('#FileListsuc tr').length+$('#FileListing tr').length),flen=files.length,fhtml,vhtml='',ehtml='';
    // 最多上传newmaxnum
	if(flen>newnum){ 
	     layer.alert("<strong>附件最多能上传"+maxnum+"个</strong>",{icon:2}); 
         uploader.splice(newnum,10000);  
        }
		
		for(var i = 0; i<=flen; i++){
			//更新UI
			if(i==flen){ 
			 if(ehtml!=''){layer.alert("<strong>以下附件已传过了，不要重复上传</strong><br>"+ehtml,{icon:0});}
			 if(uploader.files.length>0){
			 $('#pluing').show();
			 $(fhtml).appendTo('#FileListing');
			 $('#pluing u').html(uploader.files.length);
			 }
			 return false;
			}
			// 最多上传newnum
			if(i>=newnum){ 
			continue;
		    }
			fname=files[i].name;
			fid=files[i].id;
			var f5name=$.md5(files[i].size+files[i].lastModifiedDate+files[i].type);
			 vhtml='<tr id="file-' + fid +'"><td>' + fname +'</td><td></td><td align="center"><a onclick=deling("'+fid+'")>取消</a></td></tr>'
			 $("#FileListsuc :checkbox").each(function(){     
	         if($(this).val()==f5name){
             vhtml='';
			 uploader.removeFile(fid);
			 ehtml+="【"+fname+"】<br>";
			 return false;
			 }
	         });
             fhtml=fhtml+vhtml;	
		}

	});
	uploader.bind("BeforeUpload",function(uploader,file){
    uploader.setOption("multipart_params",{lastDate:file.lastModifiedDate,osize:file.size,number:'155003794971',filebh:'155006968890',type:'append',filetype:'files',maxnum:maxnum}); 
    }); 
	//进度
	uploader.bind("UploadProgress",function(uploader,file){
	$('#progress-in').width(uploader.total.percent+"%"); 
	$("#file-"+file.id+" td:eq(2)").html("<b>"+file.percent+"%</b>");
    });
	//上传完成后
	uploader.bind("FileUploaded",function(uploader, file,info){
		 $('#progress-uploaded').html(uploader.total.uploaded);
		 var data =$.parseJSON(info.response);
		 if(data.state!=0){
         $fh=$('#progress ul');
         $fh.show();
		 $('<p><span>'+file.name+'</span><br><b>'+data.state+' >> 继续执行…</b></p>').appendTo($fh);
	     stop=3000;
		 }
    });
	//全部完成后
	uploader.bind("UploadComplete",function(uploader){
		setTimeout("Rs(Rsdata)",stop);
    });
		//错误提示
		uploader.bind("Error",function(uploader,err){
		 if(err.message=='HTTP Error.'){
		 fid=err.file.id;
		 $("#file-"+fid+" td:eq(1)").html("<font color=red>系统出错，代码"+err.code+"</font>");
		 $("#file-"+fid+" td:eq(2)").html('<a onclick=deling("'+fid+'")>删除</a>');
		 return false;
		 }
		 layer.alert("<strong>"+err.message+"</strong>",{icon:5});
    });

});
</script>
<div class='notes'>
  <li> <h3>小提示：</h3></li>
<li><b>1.</b>在此可对交易追加【金额、时间、内容】。（至少追加一项，未勾选项不追加）</li>
<li><b>2.</b>不含【金额】的追加，对方同意即生效，否则需对方同意且买方付款后生效。</li>
</div>

<div class="layui-form-item append_not">
   <div class="layui-form-label"><input type="checkbox"  lay-filter="label" name="label[cyc]" class='appendday append_checkbox' value='cyc'><span class='append_label'>交易周期</span></div>
   
   <div class="layui-input-block">
    <div class="layui-inline" style='margin-right:5px'>
<input type="button" class="addred" value="+" />
<input type="text" name="daynum" data='day' id="addred_num" lay-verify="appendday" onkeyup="if(this.value<1 || this.value>60){layer.alert('交易周期，不能小于1天或大于60天',{icon:2});this.value=3;}" class="o_number" value="3"/>
<input type="button" class="addred" value="-" /></div>
<div class="layui-inline"><div class="layui-form-mid layui-word-aux">天</div></div>
</div>
</div>


<div class="layui-form-item  append_not">
   <div class="layui-form-label">
   <input type="checkbox"  lay-filter="label" class='appendmoney append_checkbox' name="label[money]" value='money'><span class='append_label'>交易金额</span>
   </div>
    <div class="layui-input-block">
    <div class="layui-inline" style='margin-right:5px'>
	<input name="money" class="layui-input o_number" value="" maxlength="10" style='width:105px;' lay-verify="appendmoney" type="text" placeholder="输入追加金额"/>
    </div>
	<div class="layui-inline"><div class="layui-form-mid layui-word-aux">元 【买方支付中介费2%（由主交易选择而定）】</div></div>
</div>
</div>
</dl>

<div class="layui-form-item  append_not">
   <div class="layui-form-label"><input type="checkbox"  class='appendtxt append_checkbox' lay-filter="label" name="label[txt]" value='txt'><span class='append_label'>交易内容</span></div>
    <div class="layui-input-block">


<div class="layui-inline">
 <input type="radio" checked name="txt_type"  value="add"  title="补充"/>
 <input type="radio"  name="txt_type" value="cover"  title="覆盖<font class=gray>（作为新的唯一交易内容，废除已有全部交易内容，含附件）</font>"/>
 </div>


<div class="upload-box" style='float:left;width:95%;'>
<p>
<textarea name="txt" class="layui-textarea checkLen" style='height:100px;width:96%;margin:10px 2% 0 2%' lay-verify="appendtxt" placeholder="追加交易内容，不能少于10个字！"></textarea>
</p>

	<div class="container">
				<div class="statusBar" >
				<div class="info"><b>1.</b>附件非必传！限上传5个,单个大小上限5M<br><b>2.</b>支持格式：jpg,png,gif,txt,pdf,doc,xls,zip,rar</div>
					<div class="btns">
					<a id="browse">上传附件</a>
					</div>
				</div>
<table  class="fu_list" id='pluing' style='display:none;' >
            <thead>
              <tr>
                <td width="65%">待传队列（<u>0</u>）</td>
				<td width="25%" align="center"></td>
                <td width="10%" align="center">操作</td>
              </tr>
            </thead>
            <tbody id="FileListing">
			</tbody>
      </table>
</div>
</div>



</div>
</div>


<div class="layui-form-item item-btn">
    <input type="button" class="layui-btn layui-btn-danger lay-submit" lay-submit=""  value="确认提交" />
	</div>

<input type="hidden" name="layer" value="1">
<input type="hidden" name="role" value="{$data.role}">
<input type="hidden" name="utime" value="{$data.utime}">
<input type="hidden" name="action" value="{$data.action}">
<input type="hidden" name="number" value="{$data.number}">
<input type="hidden" name="passkey" value="{:passkey()}">
<input type="hidden" name="append_bh" value="{:shop_bh()}">
</form>
<script type="text/javascript">
layer.title('<font color=blue style="font-weight:700;font-size:14px;">发起追加交易</font>');layui.use('form',function(){var form=layui.form();form.verify({reason_txt:function(value){if($.trim(value).length<10)return'原因不能少于10个字！'},appendday:function(value){if(!$(".appendday").is(':checked')){return}if(value<1||value>60||isNaN(value)){return'交易周期，不能小于1天或大于60天'}},appendmoney:function(value){if(!$(".appendmoney").is(':checked')){return}if(value<10||isNaN(value)){return'交易金额不能小于10元'}},appendtxt:function(value){if(!$(".appendtxt").is(':checked')){return}if(value.length<10){return'交易内容不能小于10个字'}}});form.on('checkbox(label)',function(data){if($("input[name=state_cyc]").val()==1&&data.value=='cyc'){$(data.elem).attr('checked',true);layer.alert('<b>当前交易状态，必须追加【交易周期】！</b>',{icon:0});form.render('checkbox');return false}var $div=$(data.elem).closest(".layui-form-item");(data.elem.checked)?$div.removeClass("append_not"):$div.addClass("append_not")});form.on('submit',function(data){if($(".append_checkbox:checked").length<1){layer.alert('<b>您至少要追加一项！</b>',{icon:0});return false}layer.load();dform(data.field,'append',function(datas){if(datas.state==1&&uploader.total.queued>0){Rsdata=datas;progress();$('#progress-upload').html(uploader.total.queued);uploader.start()}else{Rs(datas)}});return false});form.render()});$('.append_label').live('click',function(){$(this).prev().click();form.render('checkbox')});$(this).keydown(function(e){var key=window.event?e.keyCode:e.which;if(key.toString()=="13"){return false}});
</script>

